<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
<%@ include file="/common/common-css.jsp" %>
<style>
		#jquery-table td{cursor:pointer !important}
		.load_bg{background:#000;opacity:0.1;left:0px;top:0px;position:fixed;height:100%;width:100%;overflow:hidden;z-index:10000;}
		.load_img{left:50%;top:180px;position:fixed;height:50px;overflow:hidden;z-index:20000;}
		</style>
	</head>
<body  class="no-skin">

<div  class="load_bg" style="display:none"></div>
<img src="http://img.xmiles.cn/commentloading.gif" class="load_img" style="display:none"/>
	<div class="page-content"> 
		<form id="queryForm" action="" method="POST"> 
			<div class="page-content-area"> 
				<div class="row">
  					<div class="col-sm-12">
						<div class="widget-box" style="border:0px solid #ccc; border-top:none;border-bottom:none;margin-top:15px;">
							<hr style="margin-top:0px;margin-bottom:0x">
							  <div class="form-group col-xs-12 col-sm-4 "> 
												<label class="col-sm-2 control-label"  style="text-align:right"  for="sex">时间:</label>
												<div class="col-sm-8" style="padding-left: 0px">
										    <div class="input-daterange input-group">
												<input type="text" data-date-format="yyyy-mm-dd"
													class="date-picker input-sm form-control"
													style="padding-left: 0px" id="startTime" name="startTime"> 
												 <span class="input-group-addon" style="width: 6px"> 
												    <i class="fa fa-exchange"></i>
												 </span>
												 <input type="text" data-date-format="yyyy-mm-dd"
													class="date-picker input-sm form-control"
													style="padding-left: 0px" id="endTime" name="endTime">
											 </div>
										</div>
											</div>
							<div class=" widget-body">
								<div class="widget-main" >
								
											<div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"  style="text-align:right" >平台:</label>
												 <div class="col-sm-4">
													<div class="input-daterange input-group col-sm-6">
														<select name="platfrom">
															<option value="">全部</option>
															<option value="android">安卓</option>
															<option value="ios">ios</option>
														</select>
													</div>
												</div>
											</div>
											
											<div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"  style="text-align:right">产品：</label>
												 <div class="col-sm-4">
													<div class="input-daterange input-group col-sm-12">
															<s:select id="product" name="product" list="%{paramsMap.productList}" listKey="product_id" listValue="product_name" 
															headerKey="" headerValue="全部" cssClass="form-control"></s:select>
													</div>
												</div>
											</div>
											
											<div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"  style="text-align:right">渠道：</label>
												 <div class="col-sm-4">
													<div class="input-daterange input-group col-sm-12">
															<s:select id="channel" name="channel" list="%{paramsMap.channelList}" listKey="channel_id" listValue="channel_name" 
															headerKey="" headerValue="全部" cssClass="form-control"></s:select>
													</div>
												</div>
											</div>
											
											<div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"  style="text-align:right">活动类型：</label>
												 <div class="col-sm-4">
													<div class="input-daterange input-group col-sm-12">
															<s:select id="activityType" name="activityType" list="%{paramsMap.activityTypeList}" listKey="activityType_id" listValue="activityType_name" 
															headerKey="" headerValue="全部" cssClass="form-control"></s:select>
													</div>
												</div>
											</div>
											
											<div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"  style="text-align:right">活动ID：</label>
												 <div class="col-sm-4">
													<div class="input-daterange input-group col-sm-12">
															<s:select id="new_activity" name="new_activity" list="%{paramsMap.new_activityList}" listKey="new_activity_id" listValue="new_activity_name" 
															headerKey="" headerValue="全部" cssClass="form-control"></s:select>
													</div>
												</div>
											</div>
											
											<div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"  style="text-align:right" >环境:</label>
												 <div class="col-sm-4">
													<div class="input-daterange input-group col-sm-6">
														<select name="environment">
															<option value="">全部</option>
															<option value="1">推广H5</option>
															<option value="2">客户端</option>
														</select>
													</div>
												</div>
											</div>
		
											<div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"  style="text-align:right"  for="sex">页面:</label>
												<input type="text" id="page" name="page" placeholder="搜索">
											</div>
											
											<div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"  style="text-align:right"  for="sex">模块:</label>
												<input type="text" id="ck_module" name="ck_module" placeholder="搜索">
											</div>
											
											<div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"  style="text-align:right"  for="sex">位置:</label>
												<input type="text" id="position" name="position" placeholder="搜索">
											</div>
											
											<div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"  style="text-align:right">活动：</label>
												 <div class="col-sm-4">
													<div class="input-daterange input-group col-sm-12">
															<s:select id="source" name="source" list="%{paramsMap.sourceList}" listKey="source_id" listValue="source_name" 
															headerKey="" headerValue="全部" cssClass="form-control"></s:select>
													</div>
												</div>
											</div>
											
											<div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"  style="text-align:right" >联登类型:</label>
												 <div class="col-sm-4">
													<div class="input-daterange input-group col-sm-6">
														<select name="loginType">
															<option value="">全部</option>
															<option value="1">一键联登</option>
															<option value="2">普通联登</option>
															<option value="3">一键投递</option>
															<option value="4">熊花花联登</option>
															<option value="boluodai">菠萝贷联登</option>
														</select>
													</div>
												</div>
											</div>
											
												<div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"  style="text-align:right" >用户类型:</label>
												 <div class="col-sm-4">
													<div class="input-daterange input-group col-sm-6">
														<select name="userType">
															<option value="">全部</option>
															<option value="1">新用户</option>
															<option value="0">老用户</option>
														</select>
													</div>
												</div>
											</div>
											
											<div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"  style="text-align:right" >渠道分组:</label>
												 <div class="col-sm-4">
													<div class="input-daterange input-group col-sm-6">
														<select name="groupchannel">
															<option value="1">是</option>
															<option value="">否</option>
														</select>
													</div>
												</div>
											</div>

											<div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"
													   style="text-align: right" for="type">联登序号:</label>
												<div class="col-sm-6" style="padding-left: 0;">
													<input type="text" style="padding-left: 0px" name="type" id="type">
												</div>
											</div>
		
									</div><!-- /.widget-main -->
								</div><!-- /.widget-body -->
						</div><!-- /.widget-box -->
					</div><!-- /.col-sm-12 -->
					
					<div class="col-md-12 center">
						<div class="clearfix form-actions">
				
							<button class="btn btn-purple  no-border" type="button" name="btn-query" onclick="query_any()" id="btn-query" > 
								<i class="ace-icon fa fa-search icon-on-right bigger-110"></i> 
								查询 
							</button> 
							&nbsp;&nbsp;&nbsp;
							<button class="btn btn-grey  no-border" type="reset">
								<i class="ace-icon fa fa-undo icon-on-right bigger-110"></i>
								重置
							</button>
							
				 		 </div>
		  			 </div>
				
				</div><!-- /.row -->
				
				<div class="row">
					<div class="col-xs-12">
						<a id="loadButton" href="javascript:void(0)"
							class="btn btn-success btn-small" style="display: none"
							id="output2" onclick="loadlist()">导出CSV</a>&nbsp;&nbsp;&nbsp;
					</div>
					<!-- /.col -->
				</div>
					 
				<hr style="display:none;" id="delete_hr">
					<div class="row">
					<div class="col-xs-12">
						<table id="jquery-table" class="table table-striped table-bordered table-hover">
						</table>
					</div><!-- /.col -->
				</div><!-- /.row -->
			</div><!-- /.page-content-area -->
		</form>
	</div><!-- /.page-content -->
				
<%@ include file="/common/common-js.jsp" %>

<!-- inline scripts related to this page -->

<script type="text/javascript">

	function loadlist(){
		var form = document.forms["queryForm"];
		form.action= ctx+"/ulstat/exportData.action"; 
		form.submit();
	}

	//【查询】按钮Click事件
	function query_any() {
		$("#loadButton").show();
		$(".load_bg").removeAttr("style");
		$(".load_img").removeAttr("style");
		if (jqTable != null) {
			jqTable.fnDraw();
		} else {
			loaddata();
		}
		$("#delete_hr").attr("style", "margin-top:0px;margin-bottom:20px;display:block");
	}
	var jqTable = null;
	var loaddata = function() {
		jQuery(function($) {
			jqTable = $('#jquery-table').dataTable(
					{
						"columnDefs" : [ {
							"title" : '日期',
							"targets" : [ 0 ],
							"data" : "datetime",//返回的数据 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						}, {
							"title" : '产品',
							"targets" : [ 1 ],
							"data" : "product_id",
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						}, {
							"title" : '平台',
							"targets" : [ 2 ],
							"data" : "platform",
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						}, {
							"title" : '渠道',
							"targets" : [ 3 ],
							"data" : "channel_id", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						}, {
							"title" : '活动类型',
							"targets" : [ 4 ],
							"data" : "activity_type", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%",
						},
						{
							"title" : '活动ID',
							"targets" : [ 5 ],
							"data" : "new_activity_id", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},
						{
							"title" : '环境',
							"targets" : [ 6 ],
							"data" : "environment", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%",
							"render": function(value,type,row){
								if(value==1){
									value="推广H5";
								}else if(value==2){
									value="客户端";
								}
								return value;
							}
						},
						{
							"title" : '用户',
							"targets" : [ 7 ],
							"data" : "userType", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%",
							"render":function(value,type,row){
								if(value==1){
									value="新用户";
								}else if(value==0){
									value="老用户";
								}
								return value;
							}
						},
						{
							"title" : '页面',
							"targets" : [ 8 ],
							"data" : "page", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},
						{
							"title" : '模块',
							"targets" : [ 9 ],
							"data" : "ck_module", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},
						{
							"title" : '位置',
							"targets" : [ 10 ],
							"data" : "position", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},
						{
							"title" : '活动',
							"targets" : [ 11 ],
							"data" : "source_id", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},
						{
							"title" : '联登序号',
							"targets" : [ 12 ],
							"data" : "type",
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},
						{
							"title" : '联登类型',
							"targets" : [ 13 ],
							"data" : "loginType", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%",
							"render":function(value,type,row){
								if(value==1){
									value="一键联登";
								}else if(value==2){
									value="普通联登";
								}else if(value==3){
								    value = "一键投递";
								}else if(value==4){
								    value = "熊花花联登";
								}
								return value;
							}
						},
						{
							"title" : '请求联登人数',
							"targets" : [ 14 ],
							"data" : "loginNum", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},
						{
							"title" : '联登成功人数',
							"targets" : [ 15 ],
							"data" : "loginSuccessNum", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},
						{
							"title" : '请求联登甲方数',
							"targets" : [ 16 ],
							"data" : "jFNum", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},	
						{
							"title" : '联登成功甲方数',
							"targets" : [ 17 ],
							"data" : "jFSuccessNum", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},{
							"title" : '联登成功百分比',
							"targets" : [ 18 ],
							"data" : "SuccessNumbaifen", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%",
							"render":function(value,type,row){
								value=row.loginSuccessNum/row.loginNum*100;
								return value.toString().substring(0, 4)+"%";
							}
						}
						],
						"sAjaxSource" : ctx + "/ulstat/list.action", // 数据源URL
						"fnServerData" : function(sSource, aoData,
								fnCallback) {//从服务器请求数据
							var data = $('#queryForm').serializeObject();
							data.aoData = JSON.stringify(aoData);
							$.ajax({
								"dataType" : 'json',
								"type" : "POST",
								"url" : sSource,
								"data" : data,
								"success" : function(resp) {
									fnCallback(resp);
									initListPage();
									$(".load_bg").attr("style",
											"display:none");
									$(".load_img").attr("style",
											"display:none");
								},
								"error" : function(XMLHttpRequest,
										textStatus, errorThrown) {
									$(".load_bg").attr("style",
											"display:none");
									$(".load_img").attr("style",
											"display:none");
									alert('请求服务器错误,请刷新重试！！');//错误提示，包括服务器重启导致的session失效
								},
							});
						},
						"sScrollXInner" : "100%",
						"sScrollY" : "100%",//如果不设置，IE会有问题
						"aaSorting" : [ [ 1, "desc" ] ]
					});
		});
	}
	
	function initDate() {
		var today = GetDateStr(0);
		var beforedate = GetDateStr(-6);
		if ($.isBlank($("#startTime").val())) {
			jQuery("#startTime").val(beforedate);
		}
		if ($.isBlank($("#endTime").val())) {
			jQuery("#endTime").val(today);
		}
	}

	function GetDateStr(AddDayCount) {
		var dd = new Date();
		dd.setDate(dd.getDate() + AddDayCount);//获取AddDayCount天后的日期
		var y = dd.getFullYear();
		var m = dd.getMonth() + 1;//获取当前月份的日期
		var d = dd.getDate();
		return y + "-" + m + "-" + d;
	}
	
	//时间控件
	jQuery(function($) {
		$(".date-picker").datepicker({
			autoclose : true
		}).next().on(ace.click_event, function() {
			$(this).prev().focus();
		});
	});
	
	$(document).ready(function() {
		initDate();
		$("#product").combobox();
		$("#channel").combobox();
	});
</script>
</body>
</html>
